 


from mmdet.apis import init_detector, inference_detector, show_result_pyplot

file_root="/home/deepin/Documents/openmmlab/mmdetection/"

config_file = file_root+'configs/pascal_voc/faster_rcnn_r50_fpn_1x_voc0712.py'
# 从 model zoo 下载 checkpoint 并放在 `checkpoints/` 文件下
# 网址为: http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
checkpoint_file = file_root+'checkpoints/faster_rcnn_r50_fpn_1x_voc0712_20220320_192712-54bef0f3.pth'

device = 'cuda:0'

# 初始化检测器
model = init_detector(config_file, checkpoint_file, device=device)

# 推理 演示图像
imgpath = file_root+'data/voc2007/tain/JPEGImages/000005.jpg'
result=inference_detector(model, imgpath)

print(result)

# Let's plot the result 显示结果
show_result_pyplot(model, imgpath, result, score_thr=0.3)

# 测试显示
# python demo/image_demo.py demo/demo.jpg configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py  checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth

# 打印 cfg 文件 完整的 配置 信息 -- 并保存 到txt中
# python tools/misc/print_config.py configs/faster_rcnn/faster_rcnn_r50_caffe_c4_1x_coco.py > cfg.txt





